<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
  <base href="${pageContext.request.contextPath}/">
  <link rel="stylesheet" href="statics/layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="" method="post" lay-filter="formUpdate"  onsubmit="return false">
  <div class="layui-form-item">
    <label class="layui-form-label">角色名称</label>
    <div class="layui-input-inline">
      <input type="text" name="role_name" required lay-verify="required" autocomplete="off" class="layui-input"
             value="${sysRole.role_name}">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">权限字符</label>
    <div class="layui-input-inline">
      <input type="text" name="role_key" required lay-verify="required" autocomplete="off" class="layui-input"
             value="${sysRole.role_key}">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">显示顺序</label>
    <div class="layui-input-inline">
      <input type="text" name="role_sort" required lay-verify="required" autocomplete="off" class="layui-input"
             value="${sysRole.role_sort}">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">用户状态</label>
    <div class="layui-input-inline">
      <input type="checkbox" name="status" value="0"${sysRole.status=="0"?"checked":""} lay-skin="switch"
             lay-vayify="" lay-text="启用|禁用">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">备注</label>
    <div class="layui-input-inline">
      <input type="text" name="remark" required lay-verify="required" autocomplete="off" class="layui-input"
             value="${sysRole.remark}">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" type="submit"  lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script src="statics/layui/layui.js"></script>
<script>
  layui.use(['form','jquery'],function (){
    var $ = layui.jquery;
    var form = layui.form;
    form.on('submit(formDemo)',function (data){
      console.log(data);
      var formUpdate = form.val("formUpdate");
      $.post("${pageContext.request.contextPath}/sysRole/update",formUpdate,function (result){
        if (result){
          layer.msg("修改成功",function (){
            var index = parent.layer.getFrameIndex(window.name)
            parent.layer.close(index)
            window.parent.location.reload()
          })
        }else {
        alert("删除失败");
        }
      })
      return false;
    });
  });
</script>
</body>
</html>
